﻿<PageFunction
    x:Class="Milkify.Views.TaskEditControl"
    x:TypeArguments="sys:Boolean"
    Title="Task"
    KeepAlive="True"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:ic="clr-namespace:IronCow;assembly=IronCow"
    xmlns:m="clr-namespace:Milkify"
    xmlns:cm="clr-namespace:Milkify.ComponentModel"
    xmlns:md="clr-namespace:Milkify.Data"
    xmlns:mi="clr-namespace:Milkify.Input">
    <DockPanel>
        <DockPanel.Resources>
            <ObjectDataProvider
                ObjectType="{x:Type sys:Enum}"
                MethodName="GetValues"
                x:Key="TaskProrityValues">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="ic:TaskPriority" />
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
        </DockPanel.Resources>
        <Grid
            DockPanel.Dock="Bottom">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Button
                Name="ButtonOK"
                Grid.Column="0"
                Content="Done"
                KeyboardNavigation.TabIndex="9"
                Click="ButtonOK_Click" />
            <Button
                Name="ButtonCancel"
                Grid.Column="1"
                Content="Cancel"
                IsCancel="True"
                KeyboardNavigation.TabIndex="10"
                Click="ButtonCancel_Click" />
        </Grid>
        <Grid
            Style="{DynamicResource TaskPanelStyle}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" Style="{DynamicResource TaskPropertyTextStyle}">Task name: </TextBlock><TextBox
                Grid.Row="0"
                Grid.Column="1"
                Name="TextName"
                Text="{Binding Task.Name}"
                KeyboardNavigation.TabIndex="0"
                GotKeyboardFocus="TextBox_GotKeyboardFocus" />
            <TextBlock Grid.Row="1" Style="{DynamicResource TaskPropertyTextStyle}">List:</TextBlock><ComboBox
                Grid.Row="1"
                Grid.Column="1"
                Name="ComboList"
                KeyboardNavigation.TabIndex="1"
                SelectedValue="{Binding ParentTaskList}"
                ItemsSource="{Binding TaskLists}"
                Style="{DynamicResource TaskListComboStyle}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}" />
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <TextBlock Grid.Row="2" Style="{DynamicResource TaskPropertyTextStyle}">Priority: </TextBlock><ComboBox
                Grid.Row="2"
                Grid.Column="1"
                Name="ComboPriority"
                KeyboardNavigation.TabIndex="2"
                SelectedValue="{Binding Task.Priority}"
                ItemsSource="{Binding Source={StaticResource TaskProrityValues}}"
                Style="{DynamicResource TaskPriorityComboStyle}" />
            <TextBlock Grid.Row="3" Style="{DynamicResource TaskPropertyTextStyle}">Due: </TextBlock><TextBox
                Grid.Row="3" 
                Grid.Column="1" 
                Name="TextDue" 
                Text="{Binding Task.Due}"
                KeyboardNavigation.TabIndex="3"
                GotKeyboardFocus="TextBox_GotKeyboardFocus" />
            <TextBlock Grid.Row="4" Style="{DynamicResource TaskPropertyTextStyle}">Repeat: </TextBlock><TextBox 
                Grid.Row="4" 
                Grid.Column="1" 
                Name="TextRepeat" 
                KeyboardNavigation.TabIndex="4"
                Text="{Binding Task.Recurrence}"
                GotKeyboardFocus="TextBox_GotKeyboardFocus" />
            <TextBlock Grid.Row="5" Style="{DynamicResource TaskPropertyTextStyle}">Time estimate: </TextBlock><TextBox 
                Grid.Row="5" 
                Grid.Column="1" 
                Name="TextEstimate" 
                KeyboardNavigation.TabIndex="5"
                Text="{Binding Task.Estimate}"
                GotKeyboardFocus="TextBox_GotKeyboardFocus" />
            <TextBlock Grid.Row="6" Style="{DynamicResource TaskPropertyTextStyle}">URL: </TextBlock><TextBox 
                Grid.Row="6" 
                Grid.Column="1" 
                Name="TextUrl" 
                KeyboardNavigation.TabIndex="6"
                Text="{Binding Task.Url}"
                GotKeyboardFocus="TextBox_GotKeyboardFocus" />
            <TextBlock Grid.Row="7" Style="{DynamicResource TaskPropertyTextStyle}">Tags: </TextBlock><TextBox 
                Grid.Row="7" 
                Grid.Column="1" 
                Name="TextTags"
                KeyboardNavigation.TabIndex="7"
                GotKeyboardFocus="TextBox_GotKeyboardFocus"
                mi:TextBoxAutoComplete.WordAutoCompleteSource="{Binding Tags}"
                mi:TextBoxAutoComplete.WordAutoCompletePopup="{Binding ElementName=PopupTags}" />
            <Popup
                Name="PopupTags"
                IsOpen="False"
                Placement="Bottom"
                PlacementTarget="{Binding ElementName=TextTags}"
                Style="{DynamicResource TaskTagsPopupStyle}">
                <Grid>
                    <ListBox 
                        Name="PART_WordsHost" 
                        Style="{DynamicResource TaskTagsPopupListStyle}" />
                </Grid>
            </Popup>
            <TextBlock Grid.Row="8" Style="{DynamicResource TaskPropertyTextStyle}">Location: </TextBlock>
            <ComboBox
                Grid.Row="8"
                Grid.Column="1"
                Name="ComboLocation"
                KeyboardNavigation.TabIndex="8"
                SelectedValue="{Binding Task.Location}"
                ItemsSource="{Binding Locations}"                
                Style="{DynamicResource TaskLocationComboStyle}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}" />
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
        </Grid>
    </DockPanel>
</PageFunction>
